(function(){var t=window.AmCharts;t.AmSlicedChart=t.Class({inherits:t.AmChart,construct:function(i){this.createEvents("rollOverSlice","rollOutSlice","clickSlice","pullOutSlice","pullInSlice","rightClickSlice");t.AmSlicedChart.base.construct.call(this,i);this.colors="#FF0F00 #FF6600 #FF9E01 #FCD202 #F8FF01 #B0DE09 #04D215 #0D8ECF #0D52D1 #2A0CD0 #8A0CCF #CD0D74 #754DEB #DDDDDD #999999 #333333 #000000 #57032A #CA9726 #990000 #4B0C25".split(" ");this.alpha=1;this.groupPercent=0;this.groupedTitle="Other";this.groupedPulled=!1;this.groupedAlpha=1;this.marginLeft=0;this.marginBottom=this.marginTop=10;this.marginRight=0;this.hoverAlpha=1;this.outlineColor="#FFFFFF";this.outlineAlpha=0;this.outlineThickness=1;this.startAlpha=0;this.startDuration=1;this.startEffect="bounce";this.sequencedAnimation=!0;this.pullOutDuration=1;this.pullOutEffect="bounce";this.pullOnHover=this.pullOutOnlyOne=!1;this.labelsEnabled=!0;this.labelTickColor="#000000";this.labelTickAlpha=.2;this.hideLabelsPercent=0;this.urlTarget="_self";this.autoMarginOffset=10;this.gradientRatio=[];this.maxLabelWidth=200;this.accessibleLabel="[[title]]: [[percents]]% [[value]] [[description]]";t.applyTheme(this,i,"AmSlicedChart")},initChart:function(){t.AmSlicedChart.base.initChart.call(this);this.dataChanged&&(this.parseData(),this.dispatchDataUpdated=!0,this.dataChanged=!1,this.setLegendData(this.chartData));this.drawChart()},handleLegendEvent:function(t){var i=t.type,e=t.dataItem,a=this.legend;if(e.wedge&&e){var s=e.hidden;t=t.event;switch(i){case"clickMarker":s||a.switchable||this.clickSlice(e,t);break;case"clickLabel":s||this.clickSlice(e,t,!1);break;case"rollOverItem":s||this.rollOverSlice(e,!1,t);break;case"rollOutItem":s||this.rollOutSlice(e,t);break;case"hideItem":this.hideSlice(e,t);break;case"showItem":this.showSlice(e,t)}}},invalidateVisibility:function(){this.recalculatePercents();this.initChart();var t=this.legend;t&&t.invalidateSize()},addEventListeners:function(t,i){var e=this;t.mouseover(function(t){e.rollOverSlice(i,!0,t)}).mouseout(function(t){e.rollOutSlice(i,t)}).touchend(function(t){e.rollOverSlice(i,t)}).mouseup(function(t){e.clickSlice(i,t)}).contextmenu(function(t){e.handleRightClick(i,t)})},formatString:function(i,e,a){i=t.formatValue(i,e,["value"],this.nf,"",this.usePrefixes,this.prefixesOfSmallNumbers,this.prefixesOfBigNumbers);var s=this.pf.precision;isNaN(this.tempPrec)||(this.pf.precision=this.tempPrec);i=t.formatValue(i,e,["percents"],this.pf);i=t.massReplace(i,{"[[title]]":e.title,"[[description]]":e.description});this.pf.precision=s;-1!=i.indexOf("[[")&&(i=t.formatDataContextValue(i,e.dataContext));i=a?t.fixNewLines(i):t.fixBrakes(i);return i=t.cleanFromEmpty(i)},startSlices:function(){var t;for(t=0;t<this.chartData.length;t++)0<this.startDuration&&this.sequencedAnimation?this.setStartTO(t):this.startSlice(this.chartData[t])},setStartTO:function(t){var i=this;t=setTimeout(function(){i.startSequenced.call(i)},i.startDuration/i.chartData.length*500*t);i.timeOuts.push(t)},pullSlices:function(t){var i=this.chartData,e;for(e=0;e<i.length;e++){var a=i[e];a.pulled&&this.pullSlice(a,1,t)}},startSequenced:function(){var t=this.chartData,i;for(i=0;i<t.length;i++)if(!t[i].started){this.startSlice(this.chartData[i]);break}},startSlice:function(t){t.started=!0;var i=t.wedge,e=this.startDuration,a=t.labelSet;i&&0<e&&(0<t.alpha&&i.show(),i.translate(t.startX,t.startY),this.animatable.push(i),i.animate({opacity:1,translate:"0,0"},e,this.startEffect));a&&0<e&&(0<t.alpha&&a.show(),a.translate(t.startX,t.startY),a.animate({opacity:1,translate:"0,0"},e,this.startEffect))},showLabels:function(){var t=this.chartData,i;for(i=0;i<t.length;i++){var e=t[i];if(0<e.alpha){var a=e.label;a&&a.show();(e=e.tick)&&e.show()}}},showSlice:function(t){isNaN(t)?t.hidden=!1:this.chartData[t].hidden=!1;this.invalidateVisibility()},hideSlice:function(t){isNaN(t)?t.hidden=!0:this.chartData[t].hidden=!0;this.hideBalloon();this.invalidateVisibility()},rollOverSlice:function(i,e,a){isNaN(i)||(i=this.chartData[i]);clearTimeout(this.hoverInt);if(!i.hidden){this.pullOnHover&&this.pullSlice(i,1);1>this.hoverAlpha&&i.wedge&&i.wedge.attr({opacity:this.hoverAlpha});var s=i.balloonX,l=i.balloonY;i.pulled&&(s+=i.pullX,l+=i.pullY);var h=this.formatString(this.balloonText,i,!0),r=this.balloonFunction;r&&(h=r(i,h));r=t.adjustLuminosity(i.color,-.15);h?this.showBalloon(h,r,e,s,l):this.hideBalloon();0===i.value&&this.hideBalloon();this.fire({type:"rollOverSlice",dataItem:i,chart:this,event:a})}},rollOutSlice:function(t,i){isNaN(t)||(t=this.chartData[t]);t.wedge&&t.wedge.attr({opacity:1});this.hideBalloon();this.fire({type:"rollOutSlice",dataItem:t,chart:this,event:i})},clickSlice:function(i,e,a){this.checkTouchDuration(e)&&(isNaN(i)||(i=this.chartData[i]),i.pulled?this.pullSlice(i,0):this.pullSlice(i,1),t.getURL(i.url,this.urlTarget),a||this.fire({type:"clickSlice",dataItem:i,chart:this,event:e}))},handleRightClick:function(t,i){isNaN(t)||(t=this.chartData[t]);this.fire({type:"rightClickSlice",dataItem:t,chart:this,event:i})},drawTicks:function(){var i=this.chartData,e;for(e=0;e<i.length;e++){var a=i[e];if(a.label&&!a.skipTick){var s=a.ty,s=t.line(this.container,[a.tx0,a.tx,a.tx2],[a.ty0,s,s],this.labelTickColor,this.labelTickAlpha);t.setCN(this,s,this.type+"-tick");t.setCN(this,s,a.className,!0);a.tick=s;a.wedge.push(s);"AmFunnelChart"==this.cname&&s.toBack()}}},initialStart:function(){var t=this,i=t.startDuration,e=setTimeout(function(){t.showLabels.call(t)},1e3*i);t.timeOuts.push(e);t.chartCreated?t.pullSlices(!0):(t.startSlices(),0<i?(i=setTimeout(function(){t.pullSlices.call(t)},1200*i),t.timeOuts.push(i)):t.pullSlices(!0))},pullSlice:function(t,i,e){var a=this.pullOutDuration;!0===e&&(a=0);if(e=t.wedge)0<a?(e.animate({translate:i*t.pullX+","+i*t.pullY},a,this.pullOutEffect),t.labelSet&&t.labelSet.animate({translate:i*t.pullX+","+i*t.pullY},a,this.pullOutEffect)):(t.labelSet&&t.labelSet.translate(i*t.pullX,i*t.pullY),e.translate(i*t.pullX,i*t.pullY));1==i?(t.pulled=!0,this.pullOutOnlyOne&&this.pullInAll(t.index),t={type:"pullOutSlice",dataItem:t,chart:this}):(t.pulled=!1,t={type:"pullInSlice",dataItem:t,chart:this});this.fire(t)},pullInAll:function(t){var i=this.chartData,e;for(e=0;e<this.chartData.length;e++)e!=t&&i[e].pulled&&this.pullSlice(i[e],0)},pullOutAll:function(){var t=this.chartData,i;for(i=0;i<t.length;i++)t[i].pulled||this.pullSlice(t[i],1)},parseData:function(){var i=[];this.chartData=i;var e=this.dataProvider;isNaN(this.pieAlpha)||(this.alpha=this.pieAlpha);if(void 0!==e){var a=e.length,s=0,l,h,r;for(l=0;l<a;l++){h={};var n=e[l];h.dataContext=n;null!==n[this.valueField]&&(h.value=Number(n[this.valueField]));(r=n[this.titleField])||(r="");h.title=r;h.pulled=t.toBoolean(n[this.pulledField],!1);(r=n[this.descriptionField])||(r="");h.description=r;h.labelRadius=Number(n[this.labelRadiusField]);h.switchable=!0;h.className=n[this.classNameField];h.url=n[this.urlField];r=n[this.patternField];!r&&this.patterns&&(r=this.patterns[l]);h.pattern=r;h.visibleInLegend=t.toBoolean(n[this.visibleInLegendField],!0);r=n[this.alphaField];h.alpha=void 0!==r?Number(r):this.alpha;r=n[this.colorField];void 0!==r&&(h.color=r);h.labelColor=t.toColor(n[this.labelColorField]);s+=h.value;h.hidden=!1;i[l]=h}for(l=e=0;l<a;l++)h=i[l],h.percents=h.value/s*100,h.percents<this.groupPercent&&e++;1<e&&(this.groupValue=0,this.removeSmallSlices(),i.push({title:this.groupedTitle,value:this.groupValue,percents:this.groupValue/s*100,pulled:this.groupedPulled,color:this.groupedColor,url:this.groupedUrl,description:this.groupedDescription,alpha:this.groupedAlpha,pattern:this.groupedPattern,className:this.groupedClassName,dataContext:{}}));a=this.baseColor;a||(a=this.pieBaseColor);s=this.brightnessStep;s||(s=this.pieBrightnessStep);for(l=0;l<i.length;l++)a?r=t.adjustLuminosity(a,l*s/100):(r=this.colors[l],void 0===r&&(r=t.randomColor())),void 0===i[l].color&&(i[l].color=r);this.recalculatePercents()}},recalculatePercents:function(){var t=this.chartData,i=0,e,a;for(e=0;e<t.length;e++)a=t[e],!a.hidden&&0<a.value&&(i+=a.value);for(e=0;e<t.length;e++)a=this.chartData[e],a.percents=!a.hidden&&0<a.value?100*a.value/i:0},removeSmallSlices:function(){var t=this.chartData,i;for(i=t.length-1;0<=i;i--)t[i].percents<this.groupPercent&&(this.groupValue+=t[i].value,t.splice(i,1))},animateAgain:function(){var t=this;t.startSlices();for(var i=0;i<t.chartData.length;i++){var e=t.chartData[i];e.started=!1;var a=e.wedge;a&&(a.setAttr("opacity",t.startAlpha),a.translate(e.startX,e.startY));if(a=e.labelSet)a.setAttr("opacity",t.startAlpha),a.translate(e.startX,e.startY)}i=t.startDuration;0<i?(i=setTimeout(function(){t.pullSlices.call(t)},1200*i),t.timeOuts.push(i)):t.pullSlices()},measureMaxLabel:function(){var i=this.chartData,e=0,a;for(a=0;a<i.length;a++){var s=i[a],l=this.formatString(this.labelText,s),h=this.labelFunction;h&&(l=h(s,l));s=t.text(this.container,l,this.color,this.fontFamily,this.fontSize);l=s.getBBox().width;l>e&&(e=l);s.remove()}return e}})})();(function(){var t=window.AmCharts;t.AmPieChart=t.Class({inherits:t.AmSlicedChart,construct:function(i){this.type="pie";t.AmPieChart.base.construct.call(this,i);this.cname="AmPieChart";this.pieBrightnessStep=30;this.minRadius=10;this.depth3D=0;this.startAngle=90;this.angle=this.innerRadius=0;this.startRadius="500%";this.pullOutRadius="20%";this.labelRadius=20;this.labelText="[[title]]: [[percents]]%";this.balloonText="[[title]]: [[percents]]% ([[value]])\n[[description]]";this.previousScale=1;this.adjustPrecision=!1;this.gradientType="radial";t.applyTheme(this,i,this.cname)},drawChart:function(){t.AmPieChart.base.drawChart.call(this);var i=this.chartData;if(t.ifArray(i)){if(0<this.realWidth&&0<this.realHeight){t.VML&&(this.startAlpha=1);var e=this.startDuration,a=this.container,s=this.updateWidth();this.realWidth=s;var l=this.updateHeight();this.realHeight=l;var h=t.toCoordinate,r=h(this.marginLeft,s),n=h(this.marginRight,s),o=h(this.marginTop,l)+this.getTitleHeight(),c=h(this.marginBottom,l)+this.depth3D,u,d,p,f=t.toNumber(this.labelRadius),g=this.measureMaxLabel();g>this.maxLabelWidth&&(g=this.maxLabelWidth);this.labelText&&this.labelsEnabled||(f=g=0);u=void 0===this.pieX?(s-r-n)/2+r:h(this.pieX,this.realWidth);d=void 0===this.pieY?(l-o-c)/2+o:h(this.pieY,l);p=h(this.radius,s,l);p||(s=0<=f?s-r-n-2*g:s-r-n,l=l-o-c,p=Math.min(s,l),l<s&&(p/=1-this.angle/90,p>s&&(p=s)),l=t.toCoordinate(this.pullOutRadius,p),p=(0<=f?p-1.8*(f+l):p-1.8*l)/2);p<this.minRadius&&(p=this.minRadius);l=h(this.pullOutRadius,p);o=t.toCoordinate(this.startRadius,p);h=h(this.innerRadius,p);h>=p&&(h=p-1);c=t.fitToBounds(this.startAngle,0,360);0<this.depth3D&&(c=270<=c?270:90);c-=90;360<c&&(c-=360);s=p-p*this.angle/90;for(r=g=0;r<i.length;r++)n=i[r],!0!==n.hidden&&(g+=t.roundTo(n.percents,this.pf.precision));g=t.roundTo(g,this.pf.precision);this.tempPrec=NaN;this.adjustPrecision&&100!=g&&(this.tempPrec=this.pf.precision+1);for(var v,r=0;r<i.length;r++)if(n=i[r],!0!==n.hidden&&(this.showZeroSlices||0!==n.percents)){var m=360*n.percents/100,g=Math.sin((c+m/2)/180*Math.PI),b=s/p*-Math.cos((c+m/2)/180*Math.PI),S=this.outlineColor;S||(S=n.color);var D=this.alpha;isNaN(n.alpha)||(D=n.alpha);S={fill:n.color,stroke:S,"stroke-width":this.outlineThickness,"stroke-opacity":this.outlineAlpha,"fill-opacity":D};n.url&&(S.cursor="pointer");S=t.wedge(a,u,d,c,m,p,s,h,this.depth3D,S,this.gradientRatio,n.pattern,this.path,this.gradientType);t.setCN(this,S,"pie-item");t.setCN(this,S.wedge,"pie-slice");t.setCN(this,S,n.className,!0);this.addEventListeners(S,n);n.startAngle=c;i[r].wedge=S;0<e&&(this.chartCreated||S.setAttr("opacity",this.startAlpha));n.ix=g;n.iy=b;n.wedge=S;n.index=r;n.label=null;D=a.set();if(this.labelsEnabled&&this.labelText&&n.percents>=this.hideLabelsPercent){var C=c+m/2;0>C&&(C+=360);360<C&&(C-=360);var O=f;isNaN(n.labelRadius)||(O=n.labelRadius,0>O&&(n.skipTick=!0));var m=u+g*(p+O),k=d+b*(p+O),A,x=0;isNaN(v)&&350<C&&1<i.length-r&&(v=r-1+Math.floor((i.length-r)/2));if(0<=O){var y;90>=C&&0<=C?(y=0,A="start",x=8):90<=C&&180>C?(y=1,A="start",x=8):180<=C&&270>C?(y=2,A="end",x=-8):270<=C&&354>=C?(y=3,A="end",x=-8):354<=C&&(r>v?(y=0,A="start",x=8):(y=3,A="end",x=-8));n.labelQuarter=y}else A="middle";C=this.formatString(this.labelText,n);(O=this.labelFunction)&&(C=O(n,C));O=n.labelColor;O||(O=this.color);""!==C&&(C=t.wrappedText(a,C,O,this.fontFamily,this.fontSize,A,!1,this.maxLabelWidth),t.setCN(this,C,"pie-label"),t.setCN(this,C,n.className,!0),C.translate(m+1.5*x,k),0>f&&(C.node.style.pointerEvents="none"),C.node.style.cursor="default",n.ty=k,n.textX=m+1.5*x,D.push(C),this.axesSet.push(D),n.labelSet=D,n.label=C,this.addEventListeners(D,n));n.tx=m;n.tx2=m+x;n.tx0=u+g*p;n.ty0=d+b*p}m=h+(p-h)/2;n.pulled&&(m+=l);this.accessible&&this.accessibleLabel&&(k=this.formatString(this.accessibleLabel,n),this.makeAccessible(S,k));void 0!==this.tabIndex&&S.setAttr("tabindex",this.tabIndex);n.balloonX=g*m+u;n.balloonY=b*m+d;n.startX=Math.round(g*o);n.startY=Math.round(b*o);n.pullX=Math.round(g*l);n.pullY=Math.round(b*l);this.graphsSet.push(S);if(0===n.alpha||0<e&&!this.chartCreated)S.hide(),D&&D.hide();c+=360*n.percents/100;360<c&&(c-=360)}0<f&&this.arrangeLabels();this.pieXReal=u;this.pieYReal=d;this.radiusReal=p;this.innerRadiusReal=h;0<f&&this.drawTicks();this.initialStart();this.setDepths()}(i=this.legend)&&i.invalidateSize()}else this.cleanChart();this.dispDUpd()},setDepths:function(){var t=this.chartData,i;for(i=0;i<t.length;i++){var e=t[i],a=e.wedge,e=e.startAngle;0<=e&&180>e?a.toFront():180<=e&&a.toBack()}},arrangeLabels:function(){var t=this.chartData,i=t.length,e,a;for(a=i-1;0<=a;a--)e=t[a],0!==e.labelQuarter||e.hidden||this.checkOverlapping(a,e,0,!0,0);for(a=0;a<i;a++)e=t[a],1!=e.labelQuarter||e.hidden||this.checkOverlapping(a,e,1,!1,0);for(a=i-1;0<=a;a--)e=t[a],2!=e.labelQuarter||e.hidden||this.checkOverlapping(a,e,2,!0,0);for(a=0;a<i;a++)e=t[a],3!=e.labelQuarter||e.hidden||this.checkOverlapping(a,e,3,!1,0)},checkOverlapping:function(t,i,e,a,s){var l,h,r=this.chartData,n=r.length,o=i.label;if(o){if(!0===a)for(h=t+1;h<n;h++)r[h].labelQuarter==e&&(l=this.checkOverlappingReal(i,r[h],e))&&(h=n);else for(h=t-1;0<=h;h--)r[h].labelQuarter==e&&(l=this.checkOverlappingReal(i,r[h],e))&&(h=0);!0===l&&200>s&&isNaN(i.labelRadius)&&(l=i.ty+3*i.iy,i.ty=l,o.translate(i.textX,l),this.checkOverlapping(t,i,e,a,s+1))}},checkOverlappingReal:function(i,e,a){var s=!1,l=i.label,h=e.label;i.labelQuarter!=a||i.hidden||e.hidden||!h||(l=l.getBBox(),a={},a.width=l.width,a.height=l.height,a.y=i.ty,a.x=i.tx,i=h.getBBox(),h={},h.width=i.width,h.height=i.height,h.y=e.ty,h.x=e.tx,t.hitTest(a,h)&&(s=!0));return s}})})();
//# sourceMappingURL=pie.map.js